#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define MAX_N 600
int mtx[MAX_N][MAX_N];
int n;
char code[MAX_N*MAX_N+MAX_N];
int len;
char *p;
void solve(int tx,int ty,int sz){
    //cout <<*p << " "<<tx <<" "<<ty <<" "<<sz<<endl;
    if (*p=='\0') return ;
    if (*p=='Q') {
        sz >>= 1;
        p++;
        solve(tx,ty,sz);
        solve(tx,ty+sz,sz);
        solve(tx+sz,ty,sz);
        solve(tx+sz,ty+sz,sz);
        return ;
    }
    int i,j;
    if (*p=='W' || *p == 'B'){
        for (i = tx ; i <tx+sz ; i++)
            for (j = ty ; j <ty+sz ; j++)
                mtx[i][j] = (*p=='W'?0:1);
        p++;
    }

}

int main(){
   // freopen("2266.txt","r",stdin);
    scanf("%d",&n);
    scanf("%s",code);
    len =strlen(code);
    memset(mtx,0,sizeof(mtx));

    p=code;
    solve(0,0,n);

    printf("#define quadtree_width %d\n",n);
    printf("#define quadtree_height %d\n",n);
    printf("static char quadtree_bits[] = {\n");
    int ans ;


    for (int i = 0 ; i < n ; i++){
        ans = 0;
        for (int j = 0 ; j<n ; j++){
            ans =  ans + (mtx[i][j]<<(j%8));
            if (j%8==7){
                printf("0x%02x,",ans);
                ans = 0;
            }
        }
        if (n < 8) printf("0x%02x,",ans);
        printf("\n");
    }
    printf("};\n");
    return 0;
}
